package com.boomsecret.annotation;

import org.junit.Test;

import java.util.Map;
import java.util.Objects;

/**
 * Created by wangjinliang on 2018/1/16.
 * 统计某一个方法被调用的次数
 */
public class AnnotationTest {

    @Test
    public void testAnnotation() throws Exception {
        AnnotationTestTarget target = BeanFactory.getBeanByClass(AnnotationTestTarget.class);
        if (Objects.isNull(target)) {
            throw new Exception("target为空");
        }
        for (int i = 0; i < 6; i ++) {
            target.test1();
        }
        for (int i = 0; i < 2; i ++) {
            target.test2();
        }
        Map<Integer, Integer> methodInvokeCount = UseCaseAnnotationHandler.getMethodInvokeCount();
        System.out.println(methodInvokeCount);
    }
}
